home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / checkbox / registries / command.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  1.7 KB  |  43 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import logging
  5. from checkbox.lib.process import Process
  6. from checkbox.frontend import frontend
  7. from checkbox.properties import String
  8. from checkbox.registry import Registry
  9.  
  10. class CommandRegistry(Registry):
  11.     '''Base registry for running commands.
  12.  
  13.     The default behavior is to return the output of the command.
  14.  
  15.     Subclasses should define a command parameter.
  16.     '''
  17.     command = String()
  18.     
  19.     def __init__(self, command = None):
  20.         super(CommandRegistry, self).__init__()
  21.         if command is not None:
  22.             self.command = command
  23.         
  24.  
  25.     
  26.     def __str__(self):
  27.         logging.info('Running command: %s', self.command)
  28.         process = Process(self.command)
  29.         while process.read():
  30.             pass
  31.         if process.errdata:
  32.             logging.error('Failed to run command: %s', process.errdata.strip())
  33.         
  34.         return process.outdata
  35.  
  36.     __str__ = frontend('get_registry')(__str__)
  37.     
  38.     def items(self):
  39.         item = str(self)
  40.         return []
  41.  
  42.  
  43.